package com.bjqg.bjqg01.bjqg.activity.longrange.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.bjqg.bjqg01.bjqg.R;
import com.bjqg.bjqg01.bjqg.activity.BaseActivity;
import com.bjqg.bjqg01.bjqg.activity.address.activity.AddressManagerActivity;
import com.bjqg.bjqg01.bjqg.activity.longrange.adapter.ImageItem;
import com.bjqg.bjqg01.bjqg.activity.longrange.bean.AddressEventBean;
import com.bjqg.bjqg01.bjqg.activity.longrange.bean.EnergyBean;
import com.bjqg.bjqg01.bjqg.activity.longrange.bean.FsBean;
import com.bjqg.bjqg01.bjqg.activity.longrange.bean.MultipleBean;
import com.bjqg.bjqg01.bjqg.activity.longrange.dialog.BottomMenuDialog;
import com.bjqg.bjqg01.bjqg.activity.longrange.dialog.JcDialog;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.CydwBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.CyrBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.GcmcBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.JzdwBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.JzrBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.SgbwBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.WtdwBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.WtrBeanUtils;
import com.bjqg.bjqg01.bjqg.activity.longrange.utils.WtrPhoneBeanUtils;
import com.bjqg.bjqg01.bjqg.ui.pickview.OptionsPickerView;
import com.bjqg.bjqg01.bjqg.ui.pickview.listener.CustomListener;
import com.bjqg.bjqg01.bjqg.utils.Bimp;
import com.bjqg.bjqg01.bjqg.utils.BitmapUtils;
import com.bjqg.bjqg01.bjqg.utils.GreendaoUtils;
import com.jph.takephoto.app.TakePhoto;
import com.jph.takephoto.app.TakePhotoActivity;
import com.jph.takephoto.compress.CompressConfig;
import com.jph.takephoto.model.TImage;
import com.jph.takephoto.model.TResult;
import com.jph.takephoto.model.TakePhotoOptions;
import com.zhy.autolayout.AutoLinearLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by bjqg01 on 2018/9/7.
 */

public class EnergyActivity extends TakePhotoActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.tv_top_title_drawer)
    TextView tvTopTitleDrawer;
    @BindView(R.id.tv_search_top_drawer)
    TextView tvSearchTopDrawer;
    @BindView(R.id.tv_jllb)
    TextView tvJllb;
    @BindView(R.id.commissioned_et_wtdw)
    AutoCompleteTextView commissionedEtWtdw;
    @BindView(R.id.et_wtr)
    AutoCompleteTextView etWtr;
    @BindView(R.id.et_wtrdh)
    AutoCompleteTextView etWtrdh;
    @BindView(R.id.commissioned_et_gcmc)
    AutoCompleteTextView commissionedEtGcmc;
    @BindView(R.id.et_sgbw)
    AutoCompleteTextView etSgbw;
    @BindView(R.id.et_klsj_ggdj)
    EditText etKlsjGgdj;
    @BindView(R.id.et_klsj_jyyj)
    EditText etKlsjJyyj;
    @BindView(R.id.et_klsj_dbpl)
    EditText etKlsjDbpl;
    @BindView(R.id.et_klsj_scdw)
    EditText etKlsjScdw;
    @BindView(R.id.et_klsj_scrq)
    EditText etKlsjScrq;
    @BindView(R.id.et_klsj_zlzms)
    EditText etKlsjZlzms;
    @BindView(R.id.et_klsj_phb)
    EditText etKlsjPhb;
    @BindView(R.id.et_klsj_sb)
    EditText etKlsjSb;
    @BindView(R.id.et_klsj_lysl)
    EditText etKlsjLysl;
    @BindView(R.id.et_klsj_jcxm)
    TextView etKlsjJcxm;
    @BindView(R.id.ll_klsj_father)
    AutoLinearLayout llKlsjFather;
    @BindView(R.id.et_jrymsjbyxpmsl_ggcc)
    EditText etJrymsjbyxpmslGgcc;
    @BindView(R.id.et_jrymsjbyxpmsl_dbpl)
    EditText etJrymsjbyxpmslDbpl;
    @BindView(R.id.et_jrymsjbyxpmsl_scrq)
    EditText etJrymsjbyxpmslScrq;
    @BindView(R.id.et_jrymsjbyxpmsl_zlzms)
    EditText etJrymsjbyxpmslZlzms;
    @BindView(R.id.et_jrymsjbyxpmsl_sb)
    EditText etJrymsjbyxpmslSb;
    @BindView(R.id.et_jrymsjbyxpmsl_lysl)
    EditText etJrymsjbyxpmslLysl;
    @BindView(R.id.et_jrymsjbyxpmsl_jcxm)
    TextView etJrymsjbyxpmslJcxm;
    @BindView(R.id.ll_jrymsjbyxpmsl_father)
    AutoLinearLayout llJrymsjbyxpmslFather;
    @BindView(R.id.et_jfjbyzklbwjljc_ypmc)
    EditText etJfjbyzklbwjljcYpmc;
    @BindView(R.id.et_jfjbyzklbwjljc_ypxh)
    EditText etJfjbyzklbwjljcYpxh;
    @BindView(R.id.et_jfjbyzklbwjljc_dbsl)
    EditText etJfjbyzklbwjljcDbsl;
    @BindView(R.id.et_jfjbyzklbwjljc_bzyj)
    EditText etJfjbyzklbwjljcBzyj;
    @BindView(R.id.et_jfjbyzklbwjljc_cjmc)
    EditText etJfjbyzklbwjljcCjmc;
    @BindView(R.id.et_jfjbyzklbwjljc_sb)
    EditText etJfjbyzklbwjljcSb;
    @BindView(R.id.et_jfjbyzklbwjljc_scrq)
    EditText etJfjbyzklbwjljcScrq;
    @BindView(R.id.et_jfjbyzklbwjljc_zlzmsh)
    EditText etJfjbyzklbwjljcZlzmsh;
    @BindView(R.id.et_jfjbyzklbwjljc_phb)
    EditText etJfjbyzklbwjljcPhb;
    @BindView(R.id.et_jfjbyzklbwjljc_lysl)
    EditText etJfjbyzklbwjljcLysl;
    @BindView(R.id.et_jfjbyzklbwjljc_jcxm)
    TextView etJfjbyzklbwjljcJcxm;
    @BindView(R.id.ll_jfjbyzklbwjljc_father)
    AutoLinearLayout llJfjbyzklbwjljcFather;
    @BindView(R.id.et_njwbjy_scdw)
    EditText etNjwbjyScdw;
    @BindView(R.id.et_njwbjy_ggxh)
    EditText etNjwbjyGgxh;
    @BindView(R.id.et_njwbjy_clmc)
    EditText etNjwbjyClmc;
    @BindView(R.id.et_njwbjy_dbsl)
    EditText etNjwbjyDbsl;
    @BindView(R.id.et_njwbjy_zlzms)
    EditText etNjwbjyZlzms;
    @BindView(R.id.et_njwbjy_sb)
    EditText etNjwbjySb;
    @BindView(R.id.et_njwbjy_lysl)
    EditText etNjwbjyLysl;
    @BindView(R.id.et_njwbjy_jcxm)
    TextView etNjwbjyJcxm;
    @BindView(R.id.ll_njwbjy_father)
    AutoLinearLayout llNjwbjyFather;
    @BindView(R.id.et_jmsj_ypmc)
    EditText etJmsjYpmc;
    @BindView(R.id.et_jmsj_ggdj)
    EditText etJmsjGgdj;
    @BindView(R.id.et_jmsj_jyyj)
    EditText etJmsjJyyj;
    @BindView(R.id.et_jmsj_dbsl)
    EditText etJmsjDbsl;
    @BindView(R.id.et_jmsj_scdw)
    EditText etJmsjScdw;
    @BindView(R.id.et_jmsj_sb)
    EditText etJmsjSb;
    @BindView(R.id.et_jmsj_phb)
    EditText etJmsjPhb;
    @BindView(R.id.et_jmsj_zlzmsh)
    EditText etJmsjZlzmsh;
    @BindView(R.id.et_jmsj_lysl)
    EditText etJmsjLysl;
    @BindView(R.id.et_jmsj_jyxm)
    TextView etJmsjJyxm;
    @BindView(R.id.ll_jmsj_father)
    AutoLinearLayout llJmsjFather;
    @BindView(R.id.et_mmjj_ggxh)
    EditText etMmjjGgxh;
    @BindView(R.id.et_mmjj_jyyj)
    EditText etMmjjJyyj;
    @BindView(R.id.et_mmjj_dbsl)
    EditText etMmjjDbsl;
    @BindView(R.id.et_mmjj_cjmc)
    EditText etMmjjCjmc;
    @BindView(R.id.et_mmjj_sb)
    EditText etMmjjSb;
    @BindView(R.id.et_mmjj_phb)
    EditText etMmjjPhb;
    @BindView(R.id.et_mmjj_zlzmsh)
    EditText etMmjjZlzmsh;
    @BindView(R.id.et_mmjj_lysl)
    EditText etMmjjLysl;
    @BindView(R.id.et_mmjj_jyxm)
    TextView etMmjjJyxm;
    @BindView(R.id.ll_mmjj_father)
    AutoLinearLayout llMmjjFather;
    @BindView(R.id.et_wqbwxt_ypmc)
    EditText etWqbwxtYpmc;
    @BindView(R.id.et_wqbwxt_ggdj)
    EditText etWqbwxtGgdj;
    @BindView(R.id.et_wqbwxt_jyyj)
    EditText etWqbwxtJyyj;
    @BindView(R.id.et_wqbwxt_dbsl)
    EditText etWqbwxtDbsl;
    @BindView(R.id.et_wqbwxt_scdw)
    EditText etWqbwxtScdw;
    @BindView(R.id.et_wqbwxt_sb)
    EditText etWqbwxtSb;
    @BindView(R.id.et_wqbwxt_zlzmsh)
    EditText etWqbwxtZlzmsh;
    @BindView(R.id.et_wqbwxt_lysl)
    EditText etWqbwxtLysl;
    @BindView(R.id.et_wqbwxt_jyxm)
    TextView etWqbwxtJyxm;
    @BindView(R.id.ll_wqbwxt_father)
    AutoLinearLayout llWqbwxtFather;
    @BindView(R.id.et_jryj_ypmc)
    EditText etJryjYpmc;
    @BindView(R.id.et_jryj_ggcc)
    EditText etJryjGgcc;
    @BindView(R.id.et_jryj_zl)
    EditText etJryjZl;
    @BindView(R.id.et_jryj_jyyj)
    EditText etJryjJyyj;
    @BindView(R.id.et_jryj_dbsl)
    EditText etJryjDbsl;
    @BindView(R.id.et_jryj_scdw)
    EditText etJryjScdw;
    @BindView(R.id.et_jryj_sb)
    EditText etJryjSb;
    @BindView(R.id.et_jryj_scrq)
    EditText etJryjScrq;
    @BindView(R.id.et_jryj_zlzmsh)
    EditText etJryjZlzmsh;
    @BindView(R.id.et_jryj_lysl)
    EditText etJryjLysl;
    @BindView(R.id.et_jryj_jyxm)
    TextView etJryjJyxm;
    @BindView(R.id.ll_jryj_father)
    AutoLinearLayout llJryjFather;
    @BindView(R.id.et_mtjy_ypmc)
    EditText etMtjyYpmc;
    @BindView(R.id.et_myjy_ggxh)
    EditText etMyjyGgxh;
    @BindView(R.id.et_myjy_jyyj)
    EditText etMyjyJyyj;
    @BindView(R.id.et_myjy_dbsl)
    EditText etMyjyDbsl;
    @BindView(R.id.et_myjy_scdw)
    EditText etMyjyScdw;
    @BindView(R.id.et_myjy_sb)
    EditText etMyjySb;
    @BindView(R.id.et_myjy_zlzmsh)
    EditText etMyjyZlzmsh;
    @BindView(R.id.et_myjy_lysl)
    EditText etMyjyLysl;
    @BindView(R.id.et_myjy_jyxm)
    TextView etMyjyJyxm;
    @BindView(R.id.ll_myjy_father)
    AutoLinearLayout llMyjyFather;
    @BindView(R.id.et_xsbwg_ypmc)
    EditText etXsbwgYpmc;
    @BindView(R.id.et_xsbwg_ggdj)
    EditText etXsbwgGgdj;
    @BindView(R.id.et_xsbwg_jyyj)
    EditText etXsbwgJyyj;
    @BindView(R.id.et_xsbwg_dbsl)
    EditText etXsbwgDbsl;
    @BindView(R.id.et_xsbwg_scdw)
    EditText etXsbwgScdw;
    @BindView(R.id.et_xsbwg_sb)
    EditText etXsbwgSb;
    @BindView(R.id.et_xsbwg_zlzmsh)
    EditText etXsbwgZlzmsh;
    @BindView(R.id.et_xsbwg_lysl)
    EditText etXsbwgLysl;
    @BindView(R.id.et_xsbwg_jyxm)
    TextView etXsbwgJyxm;
    @BindView(R.id.ll_xsbwg_father)
    AutoLinearLayout llXsbwgFather;
    @BindView(R.id.et_jzj_ypmc)
    EditText etJzjYpmc;
    @BindView(R.id.et_jzj_ggdj)
    EditText etJzjGgdj;
    @BindView(R.id.et_jzj_ph)
    EditText etJzjPh;
    @BindView(R.id.et_jzj_jyyj)
    EditText etJzjJyyj;
    @BindView(R.id.et_jzj_dbsl)
    EditText etJzjDbsl;
    @BindView(R.id.et_jzj_scdw)
    EditText etJzjScdw;
    @BindView(R.id.et_jzj_sb)
    EditText etJzjSb;
    @BindView(R.id.et_jzj_sypb)
    EditText etJzjSypb;
    @BindView(R.id.et_jzj_zlzmsh)
    EditText etJzjZlzmsh;
    @BindView(R.id.et_jzj_lysl)
    EditText etJzjLysl;
    @BindView(R.id.et_jzj_jyxm)
    TextView etJzjJyxm;
    @BindView(R.id.ll_jzj_father)
    AutoLinearLayout llJzjFather;
    @BindView(R.id.et_zpsj_ypmc)
    EditText etZpsjYpmc;
    @BindView(R.id.et_zpsj_gg)
    EditText etZpsjGg;
    @BindView(R.id.et_zpsj_dj)
    TextView etZpsjDj;
    @BindView(R.id.et_zpsj_dbsl)
    EditText etZpsjDbsl;
    @BindView(R.id.et_zpsj_jyyj)
    EditText etZpsjJyyj;
    @BindView(R.id.et_zpsj_scdw)
    EditText etZpsjScdw;
    @BindView(R.id.et_zpsj_scrq)
    TextView etZpsjScrq;
    @BindView(R.id.et_zpsj_zlzmsh)
    EditText etZpsjZlzmsh;
    @BindView(R.id.et_zpsj_lysl)
    EditText etZpsjLysl;
    @BindView(R.id.et_zpsj_jcxm)
    TextView etZpsjJcxm;
    @BindView(R.id.ll_zpsj_father)
    AutoLinearLayout llZpsjFather;
    @BindView(R.id.et_hntjmclj_ypmc)
    EditText etHntjmcljYpmc;
    @BindView(R.id.et_hntjmclj_ggdj)
    EditText etHntjmcljGgdj;
    @BindView(R.id.et_hntjmclj_jyyj)
    EditText etHntjmcljJyyj;
    @BindView(R.id.et_hntjmclj_dbsl)
    EditText etHntjmcljDbsl;
    @BindView(R.id.et_hntjmclj_scdw)
    EditText etHntjmcljScdw;
    @BindView(R.id.et_hntjmclj_sb)
    EditText etHntjmcljSb;
    @BindView(R.id.et_hntjmclj_phb)
    EditText etHntjmcljPhb;
    @BindView(R.id.et_hntjmclj_zlzmsh)
    EditText etHntjmcljZlzmsh;
    @BindView(R.id.et_hntjmclj_lysl)
    EditText etHntjmcljLysl;
    @BindView(R.id.et_hntjmclj_jyxm)
    TextView etHntjmcljJyxm;
    @BindView(R.id.ll_hntjmclj_father)
    AutoLinearLayout llHntjmcljFather;
    @BindView(R.id.et_bwcl_ypmc)
    EditText etBwclYpmc;
    @BindView(R.id.et_bwcl_ggxh)
    EditText etBwclGgxh;
    @BindView(R.id.et_bwcl_jyyj)
    EditText etBwclJyyj;
    @BindView(R.id.et_bwcl_dbsl)
    EditText etBwclDbsl;
    @BindView(R.id.et_bwcl_scdw)
    EditText etBwclScdw;
    @BindView(R.id.et_bwcl_sb)
    EditText etBwclSb;
    @BindView(R.id.et_bwcl_scrq)
    EditText etBwclScrq;
    @BindView(R.id.et_bwcl_pb)
    EditText etBwclPb;
    @BindView(R.id.et_bwcl_zlzms)
    EditText etBwclZlzms;
    @BindView(R.id.et_bwcl_lysl)
    EditText etBwclLysl;
    @BindView(R.id.et_bwcl_jcxm)
    TextView etBwclJcxm;
    @BindView(R.id.ll_bwcl_father)
    AutoLinearLayout llBwclFather;
    @BindView(R.id.et_fsjcty_zj)
    TextView etFsjctyZj;

    @BindView(R.id.et_cydw)
    AutoCompleteTextView etCydw;

    @BindView(R.id.et_cyr)
    AutoCompleteTextView etCyr;

    @BindView(R.id.et_jzdw)
    AutoCompleteTextView etJzdw;
    @BindView(R.id.et_jzr)
    AutoCompleteTextView etJzr;

    @BindView(R.id.ll_jzqy)
    AutoLinearLayout llJzqy;
    @BindView(R.id.et_bz)
    EditText etBz;
    @BindView(R.id.rb_zq)
    RadioButton rbZq;
    @BindView(R.id.rb_yj)
    RadioButton rbYj;
    @BindView(R.id.rg)
    RadioGroup rg;
    @BindView(R.id.et_ddh)
    EditText etDdh;
    @BindView(R.id.ll_ddh)
    AutoLinearLayout llDdh;
    @BindView(R.id.rb_bg_zq)
    RadioButton rbBgZq;
    @BindView(R.id.rb_bg_yj)
    RadioButton rbBgYj;
    @BindView(R.id.rg_bg)
    RadioGroup rgBg;
    @BindView(R.id.tv_xzdz)
    TextView tvXzdz;
    @BindView(R.id.tv_xm)
    TextView tvXm;
    @BindView(R.id.tv_lxdh)
    TextView tvLxdh;
    @BindView(R.id.tv_yjdz)
    TextView tvYjdz;
    @BindView(R.id.ll_yj_father)
    AutoLinearLayout llYjFather;
    @BindView(R.id.btn_send)
    Button btnSend;
    @BindView(R.id.tv_ywtbh)
    TextView tvYwtbh;
    @BindView(R.id.et_bgfs)
    TextView etBgfs;
    @BindView(R.id.iv_wtd)
    ImageView ivWtd;


    List<EnergyBean> list = new ArrayList<>();
    List<String> name = new ArrayList<>();
    OptionsPickerView pvFenLei, pvFs;

    private SimpleDateFormat format;
    private String PHOTO_FILE_NAME;
    private StringBuffer sb = new StringBuffer();
    private BottomMenuDialog mButtomMenuDialog;
    private File dir;
    private boolean isFirstIn = true;//记录是否是刚进入页面
    JcDialog.Builde builde;

    List<FsBean> list1 = new ArrayList<>();
    List<String> lvname = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_energy);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
        initdata();
        initfelei();
        initfs();
    }

    private void initdata() {

        dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/PhotoPickTemp");
        if (!dir.exists()) {
            dir.mkdirs();
        }

        format = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA);

        tvTopTitleDrawer.setText(getIntent().getStringExtra("name"));
        tvSearchTopDrawer.setVisibility(View.INVISIBLE);
        tvJllb.setText("抗裂砂浆");

        list.add(new EnergyBean("抗裂砂浆", "1"));
        list.add(new EnergyBean("绝热用模塑聚苯乙烯泡沫塑料", "2"));
        list.add(new EnergyBean("胶粉聚苯乙烯颗粒保温浆料检测", "3"));
        list.add(new EnergyBean("耐碱网布检验", "4"));
        list.add(new EnergyBean("界面砂浆", "5"));
        list.add(new EnergyBean("抹面胶浆", "6"));
        list.add(new EnergyBean("外墙保温系统单个锚栓抗拉承载力", "7"));
        list.add(new EnergyBean("绝热用挤塑聚苯乙烯泡沫塑料", "8"));
        list.add(new EnergyBean("岩棉检验", "9"));
        list.add(new EnergyBean("橡塑保温管", "10"));
        list.add(new EnergyBean("胶粘剂", "11"));
        list.add(new EnergyBean("找平砂浆", "12"));
        list.add(new EnergyBean("混凝土界面处理剂", "13"));
        list.add(new EnergyBean("保温材料通用", "14"));


        for (int i = 0; i < list.size(); i++) {
            name.add(list.get(i).getName());
        }


        list1.add(new FsBean("1份  ¥0", "1"));
        list1.add(new FsBean("2份  ¥10", "2"));
        list1.add(new FsBean("3份  ¥20", "3"));
        list1.add(new FsBean("4份  ¥30", "4"));
        list1.add(new FsBean("5份  ¥40", "5"));
        list1.add(new FsBean("6份  ¥50", "6"));
        list1.add(new FsBean("7份  ¥60", "7"));
        list1.add(new FsBean("8份  ¥70", "8"));
        list1.add(new FsBean("9份  ¥80", "9"));
        list1.add(new FsBean("10份  ¥90", "10"));

        for (int i = 0; i < list1.size(); i++) {
            lvname.add(list1.get(i).getName());
        }


        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, WtdwBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "wtdw.db")));
        commissionedEtWtdw.setAdapter(adapter);


        //委托人
        ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, WtrBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "wtr.db")));
        etWtr.setAdapter(adapter2);

        //委托人电话
        ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, WtrPhoneBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "wtrdh.db")));
        etWtrdh.setAdapter(adapter3);

        //工程名称
        ArrayAdapter<String> adapter4 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, GcmcBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "gcmc.db")));
        commissionedEtGcmc.setAdapter(adapter4);

        //施工部位
        ArrayAdapter<String> adapter5 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, SgbwBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "sgbw.db")));
        etSgbw.setAdapter(adapter5);

        //抽样单位
        ArrayAdapter<String> adapter6 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, CydwBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "cydw.db")));
        etCydw.setAdapter(adapter6);

        //抽样人
        ArrayAdapter<String> adapter7 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, CyrBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "cyr.db")));
        etCyr.setAdapter(adapter7);

        //见证单位
        ArrayAdapter<String> adapter8 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, JzdwBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "jzdw.db")));
        etJzdw.setAdapter(adapter8);

        //见证人
        ArrayAdapter<String> adapter9 = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, JzrBeanUtils.listEName(GreendaoUtils.getDaoSession(EnergyActivity.this, "jzr.db")));
        etJzr.setAdapter(adapter9);
        Callphone();
    }


    @OnClick({R.id.back, R.id.btn_send, R.id.et_bwcl_jcxm, R.id.et_jrymsjbyxpmsl_jcxm, R.id.et_jfjbyzklbwjljc_jcxm,
            R.id.rb_zq, R.id.rb_yj, R.id.rb_bg_zq, R.id.rb_bg_yj, R.id.et_njwbjy_jcxm, R.id.et_zpsj_jcxm, R.id.et_jmsj_jyxm,
            R.id.tv_xzdz, R.id.tv_jllb, R.id.et_mmjj_jyxm, R.id.et_wqbwxt_jyxm, R.id.et_jryj_jyxm, R.id.et_myjy_jyxm,
            R.id.et_xsbwg_jyxm, R.id.et_jzj_jyxm, R.id.et_hntjmclj_jyxm, R.id.et_klsj_jcxm, R.id.iv_wtd, R.id.et_bgfs})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;

            case R.id.btn_send:
                Toast.makeText(this, "保存", Toast.LENGTH_SHORT).show();
                WtdwBeanUtils.insertdata(commissionedEtWtdw.getText().toString());
                WtrBeanUtils.insertdata(etWtr.getText().toString());
                WtrPhoneBeanUtils.insertdata(etWtrdh.getText().toString());
                SgbwBeanUtils.insertdata(etSgbw.getText().toString());
                GcmcBeanUtils.insertdata(commissionedEtGcmc.getText().toString());
                CydwBeanUtils.insertdata(etCydw.getText().toString());
                CyrBeanUtils.insertdata(etCyr.getText().toString());
                JzdwBeanUtils.insertdata(etJzdw.getText().toString());
                JzrBeanUtils.insertdata(etJzr.getText().toString());
                finish();
                break;

            case R.id.rb_zq://样品送达方式 自送
                llDdh.setVisibility(View.GONE);
                etDdh.setText("");
                break;
            case R.id.rb_yj://邮寄
                llDdh.setVisibility(View.VISIBLE);
                break;
            case R.id.rb_bg_zq://报告发放方式 自取
                tvXzdz.setVisibility(View.GONE);
                llYjFather.setVisibility(View.GONE);
                tvXm.setText("");
                tvLxdh.setText("");
                tvYjdz.setText("");
                break;
            case R.id.rb_bg_yj:
                tvXzdz.setVisibility(View.VISIBLE);
                break;
            case R.id.tv_xzdz://选择地址
                Intent toaddress = new Intent(EnergyActivity.this, AddressManagerActivity.class);
                toaddress.putExtra("finish", "yes");
                startActivity(toaddress);
                break;
            case R.id.tv_jllb:
                pvFenLei.show();
                break;
            case R.id.et_bwcl_jcxm:
                if (etBwclJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_klsj_jcxm:
                if (etKlsjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_jfjbyzklbwjljc_jcxm:
                if (etJfjbyzklbwjljcBzyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;

            case R.id.et_zpsj_jcxm:
                if (etZpsjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_jmsj_jyxm:
                if (etJmsjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_mmjj_jyxm:
                if (etMmjjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;

            case R.id.et_jryj_jyxm:
                if (etJryjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_myjy_jyxm:
                if (etMyjyJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_xsbwg_jyxm:
                if (etXsbwgJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_jzj_jyxm:
                if (etJzjJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_hntjmclj_jyxm:
                if (etHntjmcljJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;
            case R.id.et_wqbwxt_jyxm:
                if (etWqbwxtJyyj.getText().toString().equals("")) {
                    builde.create().show();
                } else {
                    Intent tojcxm = new Intent(this, ChoiceActivity.class);
                    startActivity(tojcxm);
                    sb.setLength(0);
                }
                break;

            case R.id.et_jrymsjbyxpmsl_jcxm:
            case R.id.et_njwbjy_jcxm:
                Intent tojcxm = new Intent(this, ChoiceActivity.class);
                startActivity(tojcxm);
                sb.setLength(0);
                break;
            case R.id.iv_wtd:
                showDialog2(view, getTakePhoto());
                break;
            case R.id.et_bgfs:
                pvFs.show();
                break;
        }
    }


    //品种分类
    private void initfelei() {
        /**
         * @description
         *
         * 注意事项：
         * 自定义布局中，id为 optionspicker 或者 timepicker 的布局以及其子控件必须要有，否则会报空指针。
         * 具体可参考demo 里面的两个自定义layout布局。
         */

        pvFenLei = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {

                String tx = list.get(options1).getName();
                tvJllb.setText(tx);

                switch (list.get(options1).getId()) {
                    case "1":
                        initvisibly();
                        llKlsjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "2":
                        initvisibly();
                        llJrymsjbyxpmslFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "3":
                        initvisibly();
                        llJfjbyzklbwjljcFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "4":
                        initvisibly();
                        llNjwbjyFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "5":
                        initvisibly();
                        llJmsjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "6":
                        initvisibly();
                        llMmjjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "7":
                        initvisibly();
                        llWqbwxtFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "8":
                        initvisibly();
                        llJryjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "9":
                        initvisibly();
                        llMyjyFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "10":
                        initvisibly();
                        llXsbwgFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "11":
                        initvisibly();
                        llJzjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "12":
                        initvisibly();
                        llZpsjFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "13":
                        initvisibly();
                        llHntjmcljFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                    case "14":
                        initvisibly();
                        llBwclFather.setVisibility(View.VISIBLE);
                        initclear();
                        break;
                }


            }
        }).setLayoutRes(R.layout.material_item, new CustomListener() {
            @Override
            public void customLayout(View v) {
                final TextView tvSubmit = (TextView) v.findViewById(R.id.tv_finish);
                TextView ivCancel = (TextView) v.findViewById(R.id.iv_cancel);
                tvSubmit.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        pvFenLei.returnData();
                        pvFenLei.dismiss();

                    }
                });

                ivCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        pvFenLei.dismiss();
                    }
                });
            }
        })
                .isDialog(false)
                .build();

        pvFenLei.setPicker(name);//添加数据
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    private void initvisibly() {
        llKlsjFather.setVisibility(View.GONE);
        llJrymsjbyxpmslFather.setVisibility(View.GONE);
        llJfjbyzklbwjljcFather.setVisibility(View.GONE);
        llNjwbjyFather.setVisibility(View.GONE);
        llJmsjFather.setVisibility(View.GONE);
        llMmjjFather.setVisibility(View.GONE);
        llWqbwxtFather.setVisibility(View.GONE);
        llJryjFather.setVisibility(View.GONE);
        llMyjyFather.setVisibility(View.GONE);
        llXsbwgFather.setVisibility(View.GONE);
        llJzjFather.setVisibility(View.GONE);
        llZpsjFather.setVisibility(View.GONE);
        llHntjmcljFather.setVisibility(View.GONE);
        llBwclFather.setVisibility(View.GONE);
    }

    private void initclear() {
        etKlsjGgdj.setText("");
        etKlsjJyyj.setText("");
        etKlsjDbpl.setText("");
        etKlsjScdw.setText("");
        etKlsjScrq.setText("");
        etKlsjZlzms.setText("");
        etKlsjPhb.setText("");
        etKlsjSb.setText("");
        etKlsjLysl.setText("");
        etKlsjJcxm.setText("");

        etJrymsjbyxpmslJcxm.setText("");
        etJrymsjbyxpmslDbpl.setText("");
        etJrymsjbyxpmslScrq.setText("");
        etJrymsjbyxpmslZlzms.setText("");
        etJrymsjbyxpmslSb.setText("");
        etJrymsjbyxpmslLysl.setText("");
        etJrymsjbyxpmslGgcc.setText("");

        etJfjbyzklbwjljcYpmc.setText("");
        etJfjbyzklbwjljcYpxh.setText("");
        etJfjbyzklbwjljcDbsl.setText("");
        etJfjbyzklbwjljcBzyj.setText("");
        etJfjbyzklbwjljcCjmc.setText("");
        etJfjbyzklbwjljcSb.setText("");
        etJfjbyzklbwjljcScrq.setText("");
        etJfjbyzklbwjljcZlzmsh.setText("");
        etJfjbyzklbwjljcPhb.setText("");
        etJfjbyzklbwjljcLysl.setText("");
        etJfjbyzklbwjljcJcxm.setText("");

        etNjwbjyScdw.setText("");
        etNjwbjyGgxh.setText("");
        etNjwbjyClmc.setText("");
        etNjwbjyDbsl.setText("");
        etNjwbjyZlzms.setText("");
        etNjwbjySb.setText("");
        etNjwbjyLysl.setText("");
        etNjwbjyJcxm.setText("");

        etJmsjYpmc.setText("");
        etJmsjGgdj.setText("");
        etJmsjJyyj.setText("");
        etJmsjDbsl.setText("");
        etJmsjScdw.setText("");
        etJmsjSb.setText("");
        etJmsjPhb.setText("");
        etJmsjZlzmsh.setText("");
        etJmsjLysl.setText("");
        etJmsjJyxm.setText("");

        etMmjjGgxh.setText("");
        etMmjjJyyj.setText("");
        etMmjjDbsl.setText("");
        etMmjjCjmc.setText("");
        etMmjjSb.setText("");
        etMmjjPhb.setText("");
        etMmjjZlzmsh.setText("");
        etMmjjLysl.setText("");
        etMmjjJyxm.setText("");

        etWqbwxtYpmc.setText("");
        etWqbwxtGgdj.setText("");
        etWqbwxtJyyj.setText("");
        etWqbwxtDbsl.setText("");
        etWqbwxtScdw.setText("");
        etWqbwxtSb.setText("");
        etWqbwxtZlzmsh.setText("");
        etWqbwxtLysl.setText("");
        etWqbwxtJyxm.setText("");

        etJryjYpmc.setText("");
        etJryjGgcc.setText("");
        etJryjZl.setText("");
        etJryjJyyj.setText("");
        etJryjDbsl.setText("");
        etJryjScdw.setText("");
        etJryjSb.setText("");
        etJryjScrq.setText("");
        etJryjZlzmsh.setText("");
        etJryjLysl.setText("");
        etJryjJyxm.setText("");

        etMtjyYpmc.setText("");
        etMyjyGgxh.setText("");
        etMyjyJyyj.setText("");
        etMyjyDbsl.setText("");
        etMyjyScdw.setText("");
        etMyjySb.setText("");
        etMyjyZlzmsh.setText("");
        etMyjyLysl.setText("");
        etMyjyJyxm.setText("");

        etXsbwgYpmc.setText("");
        etXsbwgJyyj.setText("");
        etXsbwgDbsl.setText("");
        etXsbwgScdw.setText("");
        etXsbwgSb.setText("");
        etXsbwgZlzmsh.setText("");
        etXsbwgLysl.setText("");
        etXsbwgJyxm.setText("");

        etJzjYpmc.setText("");
        etJzjGgdj.setText("");
        etJzjPh.setText("");
        etJzjJyyj.setText("");
        etJzjDbsl.setText("");
        etJzjScdw.setText("");
        etJzjSb.setText("");
        etJzjSypb.setText("");
        etJzjZlzmsh.setText("");
        etJzjLysl.setText("");
        etJzjJyxm.setText("");

        etZpsjYpmc.setText("");
        etZpsjGg.setText("");
        etZpsjDj.setText("");
        etZpsjDbsl.setText("");
        etZpsjJyyj.setText("");
        etZpsjScdw.setText("");
        etZpsjScrq.setText("");
        etZpsjZlzmsh.setText("");
        etZpsjLysl.setText("");
        etZpsjJcxm.setText("");

        etHntjmcljYpmc.setText("");
        etHntjmcljGgdj.setText("");
        etHntjmcljJyyj.setText("");
        etHntjmcljDbsl.setText("");
        etHntjmcljScdw.setText("");
        etHntjmcljSb.setText("");
        etHntjmcljPhb.setText("");
        etHntjmcljZlzmsh.setText("");
        etHntjmcljLysl.setText("");
        etHntjmcljJyxm.setText("");

        etBwclYpmc.setText("");
        etBwclGgxh.setText("");
        etBwclJyyj.setText("");
        etBwclDbsl.setText("");
        etBwclScdw.setText("");
        etBwclSb.setText("");
        etBwclScrq.setText("");
        etBwclPb.setText("");
        etBwclZlzms.setText("");
        etBwclLysl.setText("");
        etBwclJcxm.setText("");
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void XXX(AddressEventBean messageEvent) {
        if (messageEvent.getId().equals("address")) {
            tvXzdz.setVisibility(View.GONE);
            llYjFather.setVisibility(View.VISIBLE);
            tvXm.setText(messageEvent.getName());
            tvLxdh.setText(messageEvent.getPhone());
            tvYjdz.setText(messageEvent.getAddress());
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void XXl(List<MultipleBean> multiplist) {
        int price = 0;
        for (int i = 0; i < multiplist.size(); i++) {
            sb.append(multiplist.get(i).getName() + ",");
            price += multiplist.get(i).getPrice();
        }
        etFsjctyZj.setText("¥" + price);

        if (tvJllb.getText().toString().equals("抗裂砂浆")) {
            Log.d("abcde", "打印: " + sb.toString());
            etKlsjJcxm.setText(sb.toString().substring(0, sb.length() - 1));

        } else if (tvJllb.getText().toString().equals("绝热用模塑聚苯乙烯泡沫塑料")) {
            etJrymsjbyxpmslJcxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("胶粉聚苯乙烯颗粒保温浆料检测")) {
            etJfjbyzklbwjljcJcxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("耐碱网布检验")) {
            etNjwbjyJcxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("界面砂浆")) {
            etJmsjJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("抹面胶浆")) {
            etMmjjJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("外墙保温系统单个锚栓抗拉承载力")) {
            etWqbwxtJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("绝热用挤塑聚苯乙烯泡沫塑料")) {
            etJryjJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("岩棉检验")) {
            etMyjyJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("橡塑保温管")) {
            etXsbwgJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("胶粘剂")) {
            etJzjJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("找平砂浆")) {
            etZpsjJcxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("混凝土界面处理剂")) {
            etHntjmcljJyxm.setText(sb.toString().substring(0, sb.length() - 1));
        } else if (tvJllb.getText().toString().equals("保温材料通用")) {
            etBwclJcxm.setText(sb.toString().substring(0, sb.length() - 1));
        }
    }


    /**
     * 选择相册照片或者拍照
     */
    private void showDialog2(View view, final TakePhoto takePhoto) {
        mButtomMenuDialog = new BottomMenuDialog.Builder(this)
                .setShadow(true)
                .addMenu("从手机相册选择", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mButtomMenuDialog.dismiss();
                        selectPhoto(takePhoto);
                    }
                }).addMenu("拍照", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mButtomMenuDialog.dismiss();
                        PHOTO_FILE_NAME = format.format(new Date()) + ".jpg";//指定拍摄图片时 返回的文件名
                        File photo = new File(dir, PHOTO_FILE_NAME);
                        Uri uri = Uri.fromFile(photo);
                        Intent intent2 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//拍摄图片
                        intent2.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
                        intent2.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                        startActivityForResult(intent2, 201);
                    }
                }).setCancelListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        mButtomMenuDialog.dismiss();
                    }
                })
                .create();
        mButtomMenuDialog.show();
    }

    /**
     * 选择本地图片的照片
     */
    private void selectPhoto(TakePhoto takePhoto) {
        File file = new File(Environment.getExternalStorageDirectory(), "/temp/" + System.currentTimeMillis() + ".jpg");
        if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
        Uri imageUri = Uri.fromFile(file);
        configCompress(takePhoto);
        configTakePhotoOption(takePhoto);
        takePhoto.onPickMultiple(1);
    }

    private void configCompress(TakePhoto takePhoto) {
        CompressConfig config;
        config = new CompressConfig.Builder()
                .setMaxSize(200 * 1024)
                .create();

        takePhoto.onEnableCompress(config, true);
    }

    private void configTakePhotoOption(TakePhoto takePhoto) {
        TakePhotoOptions.Builder builder = new TakePhotoOptions.Builder();
        builder.setWithOwnGallery(true);
        builder.setCorrectImage(true);
        takePhoto.setTakePhotoOptions(builder.create());

    }


    /**
     * 选择照片、拍摄视频或者拍摄照片的返回结果
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /**
         * 通过相机拍照并发送
         * */
        if (requestCode == 201) {
            if (resultCode == RESULT_OK) {
                isFirstIn = false;
                File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/PhotoPickTemp/" + PHOTO_FILE_NAME);
                Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);//刷新系统媒体库
                scanIntent.setData(Uri.fromFile(new File(file.getAbsolutePath())));
                sendBroadcast(scanIntent);//发送广播 刷新当前拍摄的图片 添加到系统媒体库
                int angle = BitmapUtils.readPictureDegree(file.getAbsolutePath());
                Bitmap bitmap = BitmapUtils.compressImage(angle, BitmapUtils.decodeUri(EnergyActivity.this, Uri.fromFile(new File(file.getAbsolutePath())), 720, 1280), file.getAbsolutePath());
                ImageItem takePhoto = new ImageItem();
                takePhoto.setBitmap(bitmap);
                takePhoto.setImagePath(file.getAbsolutePath());
                if (Bimp.tempSelectBitmap.size() > 0)
                    Bimp.tempSelectBitmap.clear();

                Bimp.tempSelectBitmap.add(takePhoto);

                if (Bimp.tempSelectBitmap.size() > 0) {
                    ivWtd.setImageBitmap(Bimp.tempSelectBitmap.get(0).getBitmap());
                } else {
                    ivWtd.setImageResource(R.mipmap.a_dajiahao);
                }
            } else {
                if (isFirstIn) {
                    finish();
                }
            }
        }
    }

    @Override
    public void takeSuccess(TResult result) {
        super.takeSuccess(result);
        isFirstIn = false;
        showImg(result.getImages());
    }

    private void showImg(ArrayList<TImage> images) {
        if (Bimp.tempSelectBitmap.size() > 0)
            Bimp.tempSelectBitmap.clear();
        for (int i = 0; i < images.size(); i++) {
            ImageItem takePhoto = new ImageItem();
            takePhoto.setBitmap(BitmapUtils.decodeUri(EnergyActivity.this, Uri.fromFile(new File(images.get(i).getCompressPath())), 720, 1280));
            takePhoto.setImagePath(images.get(i).getCompressPath());
            Bimp.tempSelectBitmap.add(takePhoto);
        }
        if (Bimp.tempSelectBitmap.size() > 0) {
            ivWtd.setImageBitmap(Bimp.tempSelectBitmap.get(0).getBitmap());
        } else {
            ivWtd.setImageResource(R.mipmap.a_dajiahao);
        }
    }


    private void Callphone() {
        builde = new JcDialog.Builde(this);
        builde.setCloseListener(new DialogInterface.OnClickListener() {//确定
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent = new Intent(Intent.ACTION_CALL);
                Uri data = Uri.parse("tel:" + "02223382753");
                intent.setData(data);
                startActivity(intent);

            }
        });
        builde.setConfireListener(new DialogInterface.OnClickListener() {//取消
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
    }

    private void initfs() {
        pvFs = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {

                String tx = list1.get(options1).getName();
                etBgfs.setText(tx);

            }
        }).setLayoutRes(R.layout.material_item, new CustomListener() {
            @Override
            public void customLayout(View v) {
                final TextView tvSubmit = (TextView) v.findViewById(R.id.tv_finish);
                TextView ivCancel = (TextView) v.findViewById(R.id.iv_cancel);
                tvSubmit.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        pvFs.returnData();
                        pvFs.dismiss();

                    }
                });

                ivCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        pvFs.dismiss();
                    }
                });
            }
        })
                .isDialog(false)
                .build();

        pvFs.setPicker(lvname);//添加数据
    }
}
